package com.example.aopdemo;

import com.example.aopdemo.aop.domain.SaveOrder;
import com.example.aopdemo.aop.domain.UpdateOrder;
import com.example.aopdemo.aop.service.OrderService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class AopDemoApplication {

    /**
     * 使用自定义注解和aop方式实现对参数不同的方法做日志切面
     * @param args
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(AopDemoApplication.class, args);

        OrderService orderService = context.getBean(OrderService.class);

        SaveOrder saveOrder = new SaveOrder();
        saveOrder.setId(10L);

        /**
         * 注意查看日志，日志中已出现代理的日志
         */
        orderService.saveOrder(saveOrder);

        UpdateOrder updateOrder = new UpdateOrder();
        updateOrder.setOrderId(20L);
        orderService.updateOrder(updateOrder);
    }

}
